import logging

'''
thread save
'''

class Log:
	def __init__(self, filename, level=logging.DEBUG):
		logger = logging.getLogger();
		if filename :
			self.handler = logging.FileHandler(filename, "a+")
		else :
			self.handler = logging.StreamHandler()
		self.handler.setLevel(level);
		logger.addHandler(self.handler)

	def logMsg(self, msg, level=logging.DEBUG):
		record = logging.LogRecord(None, level, "", 0, msg, (), None, None)
		self.handler.emit(record)




